package com.sskj.mine.ui.activity;


import android.content.Intent;
import android.text.TextUtils;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.allen.library.SuperTextView;
import com.sskj.common.base.App;
import com.sskj.lib.RConfig;
import com.sskj.lib.base.BaseActivity;
import com.sskj.lib.bean.UserData;
import com.sskj.lib.model.room.UserViewModel;
import com.sskj.mine.R;
import com.sskj.mine.R2;
import com.sskj.mine.presenter.VerifyHomeActivityPresenter;
import com.sskj.mine.component.DaggerUserDataComponent;

import javax.inject.Inject;

import butterknife.BindView;

@Route(path = RConfig.MINE_SECURITY_VERIFYHOME)
public class VerifyHomeActivity extends BaseActivity<VerifyHomeActivityPresenter> {

    @BindView(R2.id.verify_first)
    SuperTextView verifyFirst;
    @BindView(R2.id.verify_second)
    SuperTextView verifySecond;
    @BindView(R2.id.ll_realName)
    LinearLayout ll_realName;
    @BindView(R2.id.ll_high)
    LinearLayout ll_high;

    @BindView(R2.id.ll_realName_drz)
    LinearLayout ll_realName_drz;
    @BindView(R2.id.ll_realName_yrz)
    LinearLayout ll_realName_yrz;
    @BindView(R2.id.ll_high_drz)
    LinearLayout ll_high_drz;
    @BindView(R2.id.ll_high_yrz)
    LinearLayout ll_high_yrz;
    @BindView(R2.id.tv_state)
    TextView tv_state;
    @BindView(R2.id.tv_high_state)
    TextView tv_high_state;
    @BindView(R2.id.tv_name)
    TextView tv_name;
    @BindView(R2.id.tv_idcard)
    TextView tv_idcard;

    private boolean firstVerify;
    private UserData mUserInfo;
    @Inject
    UserViewModel userViewModel;
    public static final int CODE = 1;


    @Override
    protected int getLayoutId() {
        return R.layout.activity_verify_home;
    }

    @Override
    public VerifyHomeActivityPresenter getPresenter() {
        return new VerifyHomeActivityPresenter();
    }

    @Override
    protected void onResume() {
        super.onResume();
        userViewModel.update();
    }

    @Override
    protected void initView() {
        super.initView();
        DaggerUserDataComponent.create().inject(this);
        setTitle(App.INSTANCE.getString(R.string.mine_verifyHomeActivity1));
        userViewModel.getUsers().observe(this, users -> {
            if (users != null && users.size() > 0) {
                mUserInfo = users.get(0);
                updateUi(mUserInfo);
            } else {
                mUserInfo = null;
            }
        });
    }

    @Override
    protected void initEvent() {
        super.initEvent();

    }

    public void updateUi(UserData user) {

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode == CODE) {
            String name = data.getExtras().getString("name");
            String card = data.getExtras().getString("card");
            if (!TextUtils.isEmpty(name) && !TextUtils.isEmpty(card)) {
                tv_name.setText(name);
                tv_idcard.setText(card);
            }
        }
    }
}
